package main

import (
	"LRU/implement"
	"fmt"
)

func main() {
	lru := implement.NewLRUCache(3)
	lru.Put(1, 1)
	lru.Put(2, 2)
	lru.Put(3, 3)
	lru.Display() // Should print: 3:3 2:2 1:1

	fmt.Println(lru.Get(2)) // Should return 2
	lru.Display()           // Should print: 2:2 3:3 1:1

	lru.Put(4, 4)
	lru.Display() // Should print: 4:4 2:2 3:3 (1 is removed)

	fmt.Println(lru.Get(1)) // Should return -1 (1 is not in the cache)

	lru.Put(2, 5)
	lru.Display() // Should print: 2:5 4:4 3:3

	fmt.Printf("----------------------\n")

	lru1 := implement.NewLRUCache1(3)
	lru1.Put(1, 1)
	lru1.Put(2, 2)
	lru1.Put(3, 3)
	lru1.Display() // 应输出: 3:3 2:2 1:1

	fmt.Println(lru1.Get(2)) // 应输出: 2
	lru1.Display()           // 应输出: 2:2 3:3 1:1

	lru1.Put(4, 4)
	lru1.Display() // 应输出: 4:4 2:2 3:3 (1 被移除)

	fmt.Println(lru1.Get(1)) // 应输出: -1 (1 已经被移除)

	lru1.Put(2, 5)
	lru1.Display() // 应输出: 2:5 4:4 3:3

}
